/**
 * @Project TMHSCFX
 * @Author Tran Manh Hung
 * @Email: hungtmit@gmail.com | tmh@xwebgate.com
 * @Copyright © 2011 TMH. All rights reserved
 * @Createdate Apr 7, 2011
 * @Createtime 2:51:51 PM
 */

package test
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.media.Sound;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.URLRequestMethod;

	import mx.formatters.NumberFormatter;

	public class Main extends Sprite
	{
		private static var numberFormat:NumberFormatter = new NumberFormatter();

		private var loader:URLLoader = new URLLoader();

		private var request:URLRequest = new URLRequest();

		public function Main()
		{
			request.url = "http://phomonline.com/music/getmusic.php";
			request.method = URLRequestMethod.GET;

			loader.addEventListener(Event.COMPLETE, loaderCompleteHandler);

			try
			{
				loader.load(request);
			}
			catch (error:Error)
			{
				trace("Unable to load URL");
			}
		}

		private function loaderCompleteHandler(event:Event):void
		{
			var sound:Sound = new Sound(new URLRequest("http://phomonline.com/music/" + event.target.data));
			sound.play();
		}

		private function test():void
		{
			numberFormat.decimalSeparatorFrom = ",";
			numberFormat.decimalSeparatorTo = ",";
			numberFormat.useThousandsSeparator = true;
			numberFormat.useNegativeSign = true;
		}

		public static function numberToNumberFormated(number:String):String
		{
			numberFormat.thousandsSeparatorFrom = "";
			numberFormat.thousandsSeparatorTo = ".";

			return numberFormat.format(number);
		}

		public static function numberFormatedToNumber(numberFormated:String):String
		{
			numberFormat.thousandsSeparatorFrom = ".";
			numberFormat.thousandsSeparatorTo = "";

			return numberFormat.format(numberFormated);
		}
	}
}